import time
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
from apscheduler.executors.pool import ThreadPoolExecutor
from common.config import yawConfig as Config
from yawSrc.yawOnl.yawOnl import yawOnl
from yawSrc.tools.toFile import toYawUploadCsv


''' MAIN ###########################################################
在线优化
'''
if __name__ == "__main__":
    # 在线优化
    executors = {
        'default': ThreadPoolExecutor(10)
    }
    main = BackgroundScheduler()
    # main.add_job(yawOnl, IntervalTrigger(seconds=Config.yawOnlDaySpan+30), id='yawOnl')
    main.add_job(toYawUploadCsv, IntervalTrigger(seconds=Config.yawUploadSpan), id='toYawUploadCsv')
    main.start()

    # 防止由于程序退出线程池被销毁
    while True:
        time.sleep(1000)